#include <bits/stdc++.h>

using namespace std;

int n;
int a[100010], k[100010];
int main()
{
    cin >> n;
    if (n == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    set<int> notVisit;
    vector<int> visited(n + 1, false);
    vector<vector<int>> graph(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        notVisit.insert(i);
    }
    for (int i = 1; i <= n; ++i)
    {
        cin >> k[i];
    }
    queue<int> q;
    q.push(1);
    notVisit.erase(1);
    notVisit.insert(n + 1);
    visited[1] = true;
    int cnt = 0;
    while (!q.empty())
    {
        ++cnt;
        int size = q.size();
        while (size--)
        {
            int v = q.front();
            q.pop();
            if (v + k[v] >= n)
            {
                cout << cnt << endl;
                return 0;
            }
            auto l = notVisit.upper_bound(v);
            auto r = notVisit.upper_bound(v + k[v]);
            // cout << v << " " << *l << " " << *r << endl;
            for (auto s = l; s != r; s = notVisit.erase(s))
            {
                int nx = (*s) - a[*s];
                // cout << "nx:" << nx << endl;
                if (nx >= n)
                {
                    cout << cnt << endl;
                    return 0;
                }
                if (!visited[nx])
                {
                    q.push(nx);
                    visited[nx] = true;
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}